home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- * *
- * PICTImport.c *
- * *
- * Translator for reading a PICT file with XTND 1.3. *
- * *
- * Copyright © 1988 Claris Corporation *
- * All Rights Reserved *
- * *
- * Author: Michael Hilton *
- * Date: 15 July, 1988 *
- * *
- ************************************************************************/
-
- #include <QuickDraw.h>
- #include <StandardFile.h>
- #include <Memory.h>
- #include <Errors.h>
-
- #include ":::XTND Headers:XTNDCIncludes:XTNDPictTranslator.h"
-
- /*------------------------- Useful Constants ---------------------------*/
-
- #define PICTHEADERSIZE 512
-
-
- /*-------------------------Function prototypes--------------------------*/
-
- void main(PictImportParmBlkPtr);
-
-
- /*----------------------------------------------------------------------*/
- /* main This is the main routine of the translator. */
- /*----------------------------------------------------------------------*/
- void main(register PictImportParmBlkPtr ourPtr)
- {
- register long savePictSize;
- register Handle thePicture;
- long pictSize;
-
- ourPtr->result = noErr;
-
- if (ourPtr->directive != importGetPict) /* Check for a valid directive */
- return;
-
- /* Determine the size of the picture (= size of the file - 512) */
- GetEOF(ourPtr->dataRefNum, &pictSize); /* Get the size of the file */
- pictSize -= PICTHEADERSIZE; /* Subtract the size of the header */
- savePictSize = pictSize; /* Save it for later */
-
- thePicture = NewHandle(pictSize); /* Create the picture handle */
- if (ourPtr->result = MemError())
- return;
-
- /* skip over the header information */
- if (ourPtr->result = SetFPos(ourPtr->dataRefNum, fsFromStart, PICTHEADERSIZE))
- return;
-
- HLock(thePicture); /* Read the picture into memory */
- if (ourPtr->result = FSRead(ourPtr->dataRefNum, &pictSize, *thePicture)) return;
- HUnlock(thePicture);
-
- if (savePictSize == pictSize) { /* If we have successfully read in a picture */
- ourPtr->thePicture = (PicHandle)thePicture;
- } else { /* We have not read all of the picture */
- DisposHandle(thePicture);
- ourPtr->result = ioErr; /* Return an error */
- }
- }
-
-